<extend name="Public/user"/>
<block name="link">
	<title>我要下单</title>
	<link href="/static/lida/css/tran_style.css" rel="stylesheet" type="text/css" />
	<link href="__CSS__/bootstrap.min.css" rel="stylesheet"/>
	<link href="__CSS__/ksfh-style.css" rel="stylesheet"/>
	<link rel="stylesheet" type="text/css" href="__CSS__/common.css">
	<link href="__CSS__/blue.css" rel="stylesheet">
	<script type="text/javascript">
		var zhuanyun_baojia = {:config('ZHUANYUN_BAOJIA')};
		var yubaocartedit = "{:url('User/yubaocartedit')}";
		var yubaocartdel = "{:url('User/yubaocartdel')}";
		var userestimatedfreight = "{:url('Public/estimatedFreight')}";
	</script>
	<script src="__JS__/jquery.js"></script>
	<script src="__JS__/icheck.min.js"></script>
	<script type="text/javascript" src="__JS__/style.js"></script>
	<script type="text/javascript" src="__STATIC__/thinkbox/thinkbox/jquery.thinkbox.js"></script>
	<script src="__JS__/bootstrap.js"></script>
	<script src="__JS__/add.js"></script>
</block>
<block name="user-right">
	<style type="text/css">
		.address-form{
			position: absolute;
			width: 270px;
			padding: 20px;
			border: 1px solid red;
			top: -1px;
			left: -1px;
			background: #fff;
			min-height: 160px;
			display: none;
			z-index: 1000;
		}
		.form-control{
			max-width: 94%;
		}
		form{
			margin: 0;
			padding: 0;
			border: none;
			list-style-type: none;

		}
		.user-right .user-address .address-form input[type="text"]{
			width: 96%;
			padding: 2%;
			border: 1px solid #dfdfdf;
		}
		.down_menu li a{
			margin: 0 8px 6px;
		}
		.num{margin-left: 3px ;margin-right: 3px;color: #AB263C;}
		.current{color: #AB263C;}
		.blank{height: 10px;clear: both;}
		.btnqx{background: #fafafa;border: 1px solid #dfdfdf;width: 48%;padding: 5px 0;float: left;cursor: pointer;text-align: center;}
		.btnqd{background: #fafafa;border: 1px solid red;width: 48%;padding: 5px 0;float: right;background: red;color:#fff;cursor: pointer;text-align: center;}
	</style>
	<!--main_right-->
	<div class="main_r f_fr">
		<div class="user_kx">
			<h3 class="user_kx_title">
				可选包裹
				<button type="button"  style="float:right;margin-top:20px;margin-left: 20px;" target-form="ids" url="{:url('User/selectAll')}"   class=" ajax-post btn btn-default">全部添加</button>
				<button type="button"  style="float:right;margin-top:20px;" target-form="ids" url="{:url('User/pull')}"   class="ajax-post btn btn-default">拉取商城订单</button>

			</h3>
			<table class="table table-striped table-bordered">

				<tbody>
				<tr>
					<th class="w90">{:lang('ex_num')}</th>
					<th class="w100">{:lang('baoguo_name')}</th>
					<th class="w80">{:lang('jiazhi')}(日元)</th>
					<!--
                                        <th class="w70">{:lang('baoguo_leixing')}</th>
                    -->
					<th class="w160">{:lang('remark')}</th>
					<th class="w80">{:lang('status')}</th>
					<th class="w100">{:lang('add_time')}</th>
					<th class="w80">{:lang('operation')}</th>
				</tr>
				<if condition="$list">
					<volist name="list" id="v">

						<tr class=""  id='yubao_info_{$v.id}'  <eq name="v.baoguo_type" value="1">style="background:#FFFFE7;color:red;"</eq>>
						<td>{$v.kuaidi_sn}</td>
						<td>{$v['baoguo_name']? $v['baoguo_name']:''}</td>
						<td>{$v['jiazhi']? $v['jiazhi']:''}</td>
						<!--
                                                <td><eq name="v.baoguo_type" value="0">{:lang('common_goods')}</eq><eq name="v.baoguo_type" value="1">{:lang('sensitive_goods')}</eq></td>
                        -->
						<td>{$v['remark']? $v['remark']:''}</td>
						<td>{$v.status|getyubaostatus}</td>
						<td>{$v.add_time|time_format='Y-m-d'}</td>
						<td>
							<if condition="($v.czstatus eq  1 )">
								<span style="color: red;margin-left: 3px;">仓转中</span>
								<else/>
								<a href="###" title="{:lang('delete')}" class="tjdd add_yundan" did="{$v.id}">添加到订单</a>
							</if>
						</td>
						</tr>
					</volist>
					<else />
					<tr >
						<td style="padding:5px;text-align: center; line-height:16px;" colspan="11">暂时没有信息</td>
					</tr>
				</if>
				</tbody>


			</table>
			<div style="word-spacing:5px; letter-spacing: 1px;">{$_page} </div>
		</div>
		<style type="text/css">
			.addedcell{position: relative;}
			.addedcell .delcell{position: absolute;top: 1px;right: 0;display: block;background: red;color: #fff;padding: 2px 10px;height: 16px;line-height: 16px;}
			.listcell{position: relative;}
			.listcell .dellistcell{position: absolute;top: 1px;right: 0;display: block;background: red;color: #fff;padding: 2px 10px;height: 16px;line-height: 16px;}
			#addresslist{display: none;position: relative;}
			.yubao-add .address-form{position: absolute;width: 285px;padding: 20px;border: 1px solid red;bottom: -35px;left: -1px;background: #fff;min-height: 160px;display: none;}
			.yubao-add .address-form input[type="text"]{width: 96%;padding: 2%;border: 1px solid #dfdfdf;}
			.yubao-add .address-form select{border: 1px solid #dfdfdf;}

		</style>
		<div class="user_kx">
			<h3 class="user_kx_title">
				预报包裹
			</h3>
			<form class="form-inline" method="post" action="{:url('User/yubaocartonly')}" id="ybcartadd">
				<table class="yubao-add table table-striped table-bordered" id="yubaoinput" style="border:none;">
					<tbody>
					<tr>
						<th class="w100">{:lang('ex_num')}*</th>
						<th class="w100">货物品名及数量*</th>
						<th class="w70">{:lang('jiazhi')}(日元)</th>
						<!--
                                                <th class="w80">{:lang('baoguo_leixing')}</th>
                                                暂时去除
                        -->
						<!--
                        <th width="75">原箱/合箱</th>
                        -->
						<th >{:lang('remark')}</th>
					</tr>
					<tr>
						<td>
							<input type="text" class="form-control" name="kuaidi_sn[]"  placeholder="{:lang('ex_num')}">
						</td>
						<td>
							<input type="text" class="form-control" name="baoguo_name[]"  placeholder="货物品名及数量">
						</td>
						<td>
							<input type="text" class="form-control" name="jiazhi[]" onkeyup="fillNumOnly(this)"  placeholder="{:lang('jiazhi')}(日元)">
						</td>
						<!--	<td >
								<select name="baoguo_type[]" class="form-control"  >
									<option value="0">{:lang('common_goods')}</option>
									<option value="1">{:lang('sensitive_goods')}</option>
								</select>
								暂时去除
							</td>-->
						<td>
							<div class="input-group">
								<input type="text" name="remark[]" class="form-control" id="inputGroupSuccess1" aria-describedby="inputGroupSuccess1Status" placeholder="{:lang('remark')}">
							</div>
						</td>
					</tr>
					</tbody>
				</table>
				<div class="user_btn">
					<button type="button" class="addonecell btn btn-default">{:lang('add_cell')}</button>
					<button type="button" class="ybcartinbtn btn btn-danger" style="background:#F00;">{:lang('insert_order')}</button>
				</div>
			</form>

		</div>
		<div class="user_kx">
			<h3 class="user_kx_title">
				{:lang('order_info')}
			</h3>
			<form action="{:url('User/yubaoadd')}" method="post" id='user-yubaoadd'>
				<table class="table table-striped table-bordered" id='yubao-adds' style="border:none;">
				 	<thead>
					    <tr>
						<!-- 	<th width="75">{:lang('ex_name')}</th>-->
						<th class="w100">{:lang('ex_num')}</th>
						<th class="w100">货物品名及数量</th>
						<th class="w70">{:lang('jiazhi')}(日元)</th>
						<!--
                                                <th class="w100">{:lang('baoguo_leixing')}</th>
                                                暂时去除
                        -->
						<!--
                        <th width="75">原箱/合箱</th>
                        -->
						<th class="w50">状态</th>
						<th  class="w100">{:lang('remark')}</th>
					</tr>
					  </thead>
					<tbody>
					
					<if condition="$ybcart">
						<volist name="ybcart" id="v">
							<tr class="list-shenbao">
								<!-- 	<td>
										<input type="text" name="kuaidi_name" class="listkdname" value="{$v.kuaidi_name}" placeholder="{:lang('ex_name')}"></td>
									--><td>
								<input type="text"	style="max-width:95%;padding: 2px 5px;"  class="form-control" value="{$v.kuaidi_sn}" placeholder="{:lang('ex_num')}"></td>
								<td>
									<input type="text"	style="max-width:95%;padding: 2px 5px;" class="form-control" value="{$v.baoguo_name}" placeholder="货物品名及数量"></td>
								<td>
									<input type="text"	style="max-width:95%;padding: 2px 5px;"  class="form-control jiazhi" value="{$v.jiazhi}" placeholder="{:lang('jiazhi')}(日元)"></td>
								<!--<td>
									<select name="baoguo_type" class="form-control">
										<option value="0" <eq name="v.baoguo_type" value="0">selected</eq>
										>{:lang('common_goods')}
										</option>
										<option value="1" <eq name="v.baoguo_type" value="1">selected</eq>
										>{:lang('sensitive_goods')}
										</option>
									</select>
									暂时去除
								</td>-->
								<td>{$v.status|getyubaostatus}</td>
								<td class="listcell">
									<!--<div class="input-group">
										<input type="text" class="form-control" id="inputGroupSuccess1" aria-describedby="inputGroupSuccess1Status" placeholder="备注">
										<a href="#" class="input-group-addon dellistcell" style="color:#FFF; background:#F00;">删除</a>

									</div>-->
									<div class="input-group" style="position:relative;">
										<input type="text" name="remark" style="max-width:95%;padding: 2px 0px;" class="form-control" id="inputGroupSuccess1" value="{$v.remark}" aria-describedby="inputGroupSuccess1Status" placeholder="{:lang('remark')}">
										<a href="###" class="input-group-addon dellcell" data-id="{$v.id}" style="color:#FFF; background:#F00;">删除</a>
									</div>

								</td>
						</volist>
						<else />
						<tr>
							<td colspan="8" id="no_infos" style="padding:5px;text-align: center;">{:lang('no_infos')}</td>
						</tr>
					</if>
					</tbody>
				</table>
				<table class="table table-striped table-bordered">
					<tbody>
					<tr>
						<th style="width:50%; text-align:center;">{:lang('delivery_address')}</th>
						<th style="width:50%; text-align:center;">{:lang('shipping_method')}</th>
						<!--
                       </td>-->
					</tr>
					<tr>
						<td style="width:50%;border:none; border-right:1px solid #CCC; padding:10px; border-bottom:1px solid #CCC;">
							<div style="line-height:25px;" id="defaddress">
								<if condition="$address">
									<div style="margin-bottom: 20px;">
										{:lang('consignee')}：{$address.true_name} &nbsp;&nbsp;{:lang('telphone')}：{$address.mob_phone}<br>
										{:lang('country')}：{$address.area_info} <br>
										{:lang('address')}：{$address.address}  <br>
									</div>
								</if>
								<input type="hidden" name="address_id" id="addressinputid" value="{$address.address_id}">
								<a href="###" id="newaddress" style=" color:#F00;">{:lang('check')}{:lang('delivery_address')}</a>
							</div>
							<div id="addresslist">
								<ul>
									<volist name="addresslist" id="v">
										<li style="padding: 5px 0;border-bottom: 1px dashed #dfdfdf;height:25px;">
											<span style="float: left;width: 25px;">
												<input type="radio" name='addressid' value="{$v.address_id}" class="addressid" <eq name="v.is_default" value="1">checked</eq>/>
										</span>
											<span style="float: left;display: block;">
											{$v.true_name} ({$v.mob_phone})&nbsp;{$v.area_info} &nbsp; {$v.address}
										</span>
											<div class="clear"></div>
										</li>
									</volist>

								</ul>
								<div class="blank"></div>
								<a href="###" class="btnqx addnewaddress">使用新地址</a>
								<a href="###" class="btnqd querenaddress">{:lang('confirm_select')}</a>
								<div class="address-form">

									<input type="text" name="consignee"  placeholder="{:lang('consignee')}">
									<div class="blank"></div>
									<input type="text" name="tel"  placeholder="{:lang('mobile')}">
									<div class="blank"></div>
									<select name="areaid" style="width:100%;">
										<option value="0">{:lang('select_country')}</option>
										<volist name=":config('AREA_INFO')" id="v">
											<option value="{$key}">{$v}</option>
										</volist>
									</select>
									<div class="blank"></div>
									<textarea name="address" placeholder="{:lang('city_street')}" style="width: 96%;padding: 2%;"></textarea>
									<div class="blank"></div>
									<input type="text" name="zipcode" placeholder="{:lang('zipcode')}">
									<div class="blank"></div>
									<div style="">
										<button type="button" class="btnqx quxiaoaddaddress">{:lang('cancel')}</button>
										<button type="button" class="btnqd querenaddaddress">{:lang('confirm_address')}</button>
									</div>

								</div>
							</div>
						</td>

						<td style="width:50%;border:none; padding:20px 50px;">
						
							<div class="form-group">
								<label for="exampleInputName2">转运模式：</label> 
								<select  class="form-control input-sm" name='transport_id' id="transport_id">
									<option value='0'>请选择</option>
								<volist name='transport' id='tp'>
									<option value='{$tp.id}'>{$tp.name}</option>
								</volist>
								</select>
							</div> 
							<div class="form-group">
								<label for="exampleInputName3">运输路线</label> 
								<select class="form-control input-sm" change ='estimatedFreight()'  name='transport_line_id'id="transport_line_id">
									<option value='0'>请选择转运模式</option>
								</select>
							</div> 
						</td>

					</tr>

					</tbody>
				</table>

				<table class="table table-bordered">
					<tbody>
					<tr>
						<td>

							<div class="checkbox">
								<label class="checkbox-inline">
									<input type="checkbox" name="yunfei" id="yunfei"  value="1" > 同意直接扣除运费快速发货（余额大于{:config('ZHUANYUN_LOW_YUNFEI')}日元）
								</label>
							</div>

						</td>
					</tr>
					<tr>
						<td>
							<span style="color:#F00;"><strong>选择增值服务：</strong></span>
							<volist name='increment' id='it'>
								<label class="checkbox-inline">
                                    <input type="checkbox" class='my-increment' value="{$it.id}" name="increment[]"> {$it.name}（{$it.intro}）
							    </label>
							</volist>
						</td>
					</tr>
				<!-- 	<tr >
						<td>
							<span style="color:#F00;"><strong>选择增值服务：</strong></span>
							<input type="radio" name="jiagu"  checked="checked" value="-1" style="margin-right:5px;" >无需加固（0日元）
							<input type="radio" name="jiagu"  value="0"  style="margin-right:5px;">简易加固（{:config('ZHUANYUN_JIAGU_EASY')}日元）
							<input type="radio" name="jiagu"   value="1"  style="margin-right:5px;">超级加固（<php>echo C('ZHUANYUN_JIAGU_2')+C('ZHUANYUN_JIAGU_2_LEVEL')</php>日元起，每5kg增加{:config('ZHUANYUN_JIAGU_2_LEVEL')}日元）<br><br>
						</td>
					</tr> -->
						<tr style="display: none;">
                            <td>
                                <span style="color:#F00;"><strong>加急服务：</strong></span>

                                <label>
                                    <input type="checkbox" name="jiaji"   value="1"  style="margin-right:5px;">加急（{:config('ZHUANYUN_JIAJI')}日元）
                                </label>


                            </td>
                        </tr>
        

					<tr>
						<td>
							<span style="color:#F00;"><strong>选择保价服务：</strong></span>

							<label class="radio-inline">
								<input type="radio" name="baojia"  id='baojiac'  checked="checked" value="0" style="margin-right:3px;" >无需保价
							</label>
							<label class="radio-inline">
								<input type="radio" name="baojia" id='baojiac'  value="1" style="margin-right:5px;"  >保价
							</label>
						</td>
					</tr>
					<tr>
						<td>
							<div class="form-group">
								<label for="exampleInputName3">
									<span style="color:#F00;"><strong>{:lang('all_jiazhi')}：</strong></span>
								</label> 
								<input type="text" onkeyup="estimatedFreight(this);"
									style='width: 10%; border: dotted #009;' id='allshenbao'
									name='shenbao' value=''> <label for="exampleInputEmail2">(日元)预计运费
									:<span id='estimated-freight'>0</span>&nbsp;(日元)
								</label><label  style="color: red" >详情：<span id ='estimated-freight-info'></span></label>
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<span style="float:left;"></span><textarea name="remark" class="form-control" rows="3" id="dingdanremark" placeholder="{:lang('remark')}"></textarea>
						</td>
					</tr>
					</tbody>
				</table>
				<div class="user_tj f_fr">
					<button type="button" class="btn btn-default tijiaodingdan" data-form='user-yubaoadd' style="background:#F00;">{:lang('submit_order')}</button>
				</div>
			</form>
		</div>
	</div>
</block>

<block name="javascript">
	<script type="text/javascript">
	$('#transport_line_id').change(function(){
		estimatedFreight();
	});
	$('input[name="increment[]"]').on('ifChanged', function(e) {
		estimatedFreight();
    })
	$('input[name="baojia"]').on('ifChanged', function(e) {
		setTimeout("estimatedFreight()",600)
		//estimatedFreight();
    })
	//转运模式选择
	$("#transport_id").change(function(){
		$("#transport_line_id").empty();
		$("#transport_line_id").append("<option value='0'>请选择</option>");
		var that = this;
		$.post("{:url('Public/transport')}",{'transport_id':that.value},function(result){
			if (0 == result.status) {
				for (var i=0;i<result.lists.length;i++)
				{
					$("#transport_line_id").append("<option value='"+result['lists'][i]['transport_line_id']+"'>"+result['lists'][i]['transport_line_name']+"</option>");
				}
			}else{
				$.thinkbox.error(result.message);
			};
		})
	});
	</script>
	<script type="text/javascript">
		$('.add_yundan').click(function(){
			var id=$(this).attr('did');
			$("#yubao_info_"+id).remove();
			$.post("{:url('User/select')}",{'yubao_id':id,'selected':1},function(result){
				if (result.status) {
					$('#no_infos').empty();
					$('#yubao-adds').append(result.info);
					location.reload();
				}else{
					$.thinkbox.error(result.info);
				};
			})


		});
		
		$(function(){

			setShenbao();
			$('.tijiaodingdan').click(function(){
				var that = this;
				/*
				var oDateJd =new Date();
				var oDateNow=new Date();
		
				oDateJd.setHours(23);
				oDateJd.setMinutes(59);
				oDateJd.setSeconds(59);
		
				oDateJd.setDate(8);
				oDateJd.setMonth(3);
				oDateJd.setFullYear(2018);
		
				if(oDateNow.getTime() > oDateJd.getTime())
				{
					$.thinkbox.error('本次船期，系统已经截单，请等待下一个船期! 若需紧急出库请联系客服！');
					return;
				}
				*/
				if(0 == $('.list-shenbao').size() ){
					$.thinkbox.error('包裹列表为空不能提交订单!');
					return;
				}
				if(0 == $('#transport_line_id').val()){
					$.thinkbox.error('请选择运送方式！');
					return;

				}
				$.post($('#'+$(that).data('form')).attr('action'),$('#'+$(that).data('form')).serialize(),function(data){
					if (data.status) {
						$.thinkbox.success(data.info);
						setTimeout(jumpurl(data.url),1000);
					}else{
						$.thinkbox.error(data.info);
					};
				});
			})
				//ajax post submit请求
			$('.ajax-post').click(function(){
				var target,query;
				var target = $(this).attr('url');
				var target_form = $(this).attr('target-form');
				var that = this;
				query =  $('.'+target_form).serialize();
				$.post(target,query).success(function(data){
					location.reload();
				});

			});
			$('.querenaddress').click(function(){
				var id=$('.addressid:checked').val();
				$.post("{:url('User/changeaddress')}",{'id':id},function(data){
					if (data.status) {
						$.thinkbox.success(data.info);
						setTimeout('location.reload()',700);
					};
				})
			})
			$('.querenaddaddress').click(function(){
				var consignee=$(this).parents('.address-form').find('input[name="consignee"]').val();
				var tel=$(this).parents('.address-form').find('input[name="tel"]').val();
				var areaid=$(this).parents('.address-form').find('select[name="areaid"]').val();
				var address=$(this).parents('.address-form').find('textarea[name="address"]').val();
				var zipcode=$(this).parents('.address-form').find('input[name="zipcode"]').val();
				$.post("{:url('User/addressadd')}",{'consignee':consignee,'tel':tel,'areaid':areaid,'address':address,'zipcode':zipcode},function(data){
					if (data.status) {
						$.thinkbox.success(data.info);
						setTimeout('location.reload()',700);
					}else{
						$.thinkbox.error(data.info);
					};
				})
			})
			$('.addonecell').click(function(){
				//	var html='<tr><td><input type="text" name="kuaidi_name[]"  placeholder="{:lang(\'ex_name\')}"></td><td><input type="text" name="kuaidi_sn[]"  placeholder="{:lang(\'ex_num\')}"></td><td><input type="text" name="baoguo_name[]"  placeholder="货物品名及数量"></td><td><input type="text" name="jiazhi[]"  placeholder="{:lang(\'jiazhi\')}(日元)"></td><td><select name="baoguo_type[]"><option value="0">{:lang(\'common_goods\')}</option><option value="1">{:lang(\'sensitive_goods\')}</option></select></td><td><select name="is_chaibao[]"><option value="0">原箱</option><option value="1" selected>合箱</option></select></td><td  class="addedcell"><input type="text" name="remark[]" placeholder="{:lang(\'remark\')}"><a href="###" class="delcell">{:lang(\'delete\')}</a></td></tr>';
				//var html='<tr><td><input type="text" class="form-control" name="kuaidi_sn[]"  placeholder="{:lang(\'ex_num\')}"></td><td><input type="text" class="form-control" name="baoguo_name[]"  placeholder="货物品名及数量"></td><td><input type="text" class="form-control" name="jiazhi[]" onkeyup="fillNumOnly(this)"  placeholder="{:lang(\'jiazhi\')}(日元)"></td><td ><select name="baoguo_type[]" class="form-control"  ><option value="0">{:lang(\'common_goods\')}</option><option value="1">{:lang(\'sensitive_goods\')}</option></select></td><td><div class="input-group"><input type="text" name="remark[]" class="form-control" id="inputGroupSuccess1" aria-describedby="inputGroupSuccess1Status" placeholder="{:lang(\'remark\')}"><a href="###" class="input-group-addon delcell" style="color:#FFF; background:#F00;">{:lang(\'delete\')}</a></div></td></tr>';
				var html='<tr><td><input type="text" class="form-control" name="kuaidi_sn[]"  placeholder="{:lang(\'ex_num\')}"></td><td><input type="text" class="form-control" name="baoguo_name[]"  placeholder="货物品名及数量"></td><td><input type="text" class="form-control" name="jiazhi[]" onkeyup="fillNumOnly(this)"  placeholder="{:lang(\'jiazhi\')}(日元)"></td><td><div class="input-group"><input type="text" name="remark[]" class="form-control" id="inputGroupSuccess1" aria-describedby="inputGroupSuccess1Status" placeholder="{:lang(\'remark\')}"><a href="###" class="input-group-addon delcell" style="color:#FFF; background:#F00;">{:lang(\'delete\')}</a></div></td></tr>';

				$('#yubaoinput').append(html);
			})
			$('.address-del').click(function(){
				var id=$(this).attr('did');
				$.post("{:url('User/addressdel')}",{'id':id},delsuccess);
				return false;
				function delsuccess(data){
					if (data.status) {
						$.thinkbox.success(data.info);
						setTimeout(jumpurl(data.url),1500);
					}else{
						$.thinkbox.error(data.info);
					};
				}
			})
		$('input').iCheck({
			checkboxClass : 'icheckbox_minimal-blue',
			radioClass : 'iradio_minimal-blue',
			increaseArea : '20%' // optional
		});
		$('#newaddress').click(function(){
			$(this).parent().hide();
			$(this).parent().next().show();
		});
		$('.ybcartinbtn').click(function(){
			$('#ybcartadd').submit();
		});
		$(document).on('click','.delcell',function(){
			$(this).parents('tr').remove();
		})
		$('.listkdname,.listkdsn,.listbgname,.listshenbao,.listbgleixing,.listchaibao,.listremark').change(function(){
			var id=$(this).parent().parent().find('.listid').val();
			var field=$(this).attr('name');
			var value=$(this).val();
			var item=$(this);
			$.post(yubaocartedit,{'id':id,'field':field,'value':value},function(data,item){
				if (data.status) {
					var allshenbao1=0;
					$('.listshenbao').each(function(){
						allshenbao1+= parseFloat($(this).val());
					});
					allshenbao1=allshenbao1.toFixed(2);
					$('#allshenbao').html(allshenbao1);
				}else{
					result=data.info;
					$('.listid').each(function(){
						if (result.data.id==$(this).val()) {
							$(this).parent().find('.list'+result.field).val(result['data'][result.field]).focus();
						};
					})
					$.thinkbox.error(result.info);
				};
			})
		})
		$('.dellcell').click(function(){
			var id = $(this).data('id');
			$.post(yubaocartdel,{'id':id},function(data){
				if (data.status) {
					$('.listid').each(function(){
						if (data.info==$(this).val()) {
							$(this).parent().remove();
						};
						location.reload();
					})
				}else{
					$.thinkbox.error(data.info);
				};
			});
		});
		$('form').submit(function(){
			var self = $(this);
			$.post(self.attr("action"), self.serialize(), success, "json");
			return false;
			function success(data){
				if (data.status) {
					//$.thinkbox.success(data.info);
					window.location.href=data.url;
					//setTimeout(jumpurl(data.url),50);
				}else{
					$.thinkbox.error(data.info);
				};
			}
		});
		$('.addnewaddress').click(function(){
			window.location.href = '/store/member/index.php?act=member_address&op=address';
			//$(this).parent().find('.address-form').show();
		})
		$('.quxiaoaddaddress').click(function(){
			$(this).parents('.address-form').hide();
		})
	});
	</script>
</block>